﻿using System;

namespace Basics103_ControlStructures
{
    /// <summary>
    /// Author: Mr. Jin Vincent N. Necesario
    /// Level: Beginner
    /// Problem: A palindrome is a number or a text phrase that reads the same backwards as forwards.
    /// For example, each of the following five digit are palindromes: 12321, 55555, 45554 and 11611.
    /// Write an application that reads in a five digit and determnise whether it is a palindrome.
    /// Test Case:
    /// Input: 55555
    /// Output: It is a valid 'PALINDROME NUMBER'
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            bool done = false;

            while (!done)
            {
                Console.WriteLine("Enter a collection of number(s) which has a length of 5 characters");

                string palindrome = Console.ReadLine().Substring(0, 5);

                if (palindrome.Length == 5)
                {
                    if ((palindrome[0] == palindrome[4]) && (palindrome[1] == palindrome[3]))
                    {
                        Console.WriteLine("It is a valid 'PALINDROME NUMBER'");
                    }
                    else
                    {
                        Console.WriteLine("It is not a valid 'PALINDROME NUMBER'");
                    }
                }

                Console.WriteLine("Do you want to try again ? [y/n]");

                string ans = Console.ReadLine();

                if (ans.ToUpper() == "N")
                {

                    done = true;
                }
            }

            Console.WriteLine("Press any key to continue ....");

            Console.ReadKey();
        }
    }
}
